Function Reference

_AD_GetManagedBy

Retrieves all groups that are managed by any or the specified user.

#Include <AD.au3>
_AD_GetManagedBy([$sManagedBy = "*"])

 

Parameters

$sManagedBy Optional: Manager to filter the list of groups (default = *). Can be a SAMAccountname or a FQDN

 

Return Value

Success: Returns a one-based two dimensional array with the following information:
    0 - distinguished name of the group
    1 - distinguished name of the manager for this group
Failure: "", sets @error to:
    1 - $sManagedBy is unknown
    2 - No groups found. @extended is set to the error returned by LDAP

 

Remarks

This query returns all groups that have the attribute "managedBy" set or set to the specified manager.

To get a list of all groups that manager x manages (by querying just the user object) use:
$Result = _AD_GetObjectAttribute("samAccountName of the manager","managedObjects")
_ArrayDisplay($Result)

To return managers for OUs change "objectCategory=group" to "objectClass=organizationalUnit".

 

Related

 

Example


#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y
#include <AD.au3>

; Open Connection to the Active Directory
_AD_Open()
If @error Then Exit MsgBox(16, "Active Directory Example Skript", "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended)

Global $aManagedBy[1][2]
Global $bNotFound = False
; *****************************************************************************
; Example 1
; Get a list of groups that have the attribute "managedBy" set
; *****************************************************************************
$aManagedBy = _AD_GetManagedBy()
If @error > 0 Or $aManagedBy[0][0] = 0 Then
    MsgBox(64, "Active Directory Functions - Example 1", "No managed groups could be found")
    $bNotFound = True
Else
    _ArrayDisplay($aManagedBy, "Active Directory Functions - Example 1 - groups managed by")
EndIf

; *****************************************************************************
; Example 2
; Get a list of groups that are managed by the first manager found in example 1
; *****************************************************************************
If $bNotFound Then
    MsgBox(64, "Active Directory Functions - Example 2", "Can't run example 2 because example 1 returned no data")
    Exit
EndIf
Global $Result = _AD_GetObjectAttribute(_AD_FQDNToSamAccountName($aManagedBy[1][1]), "managedObjects")
_ArrayDisplay($Result, "Active Directory Functions - Example 2 - groups managed by '" & $aManagedBy[1][1] & "'")

; Close Connection to the Active Directory
_AD_Close()